package com.pine.sunshineelder.common.converter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

import org.springframework.core.convert.converter.Converter;


public class LocalDateTimeConverter implements Converter<String, LocalDateTime> {

	@Override
	public LocalDateTime convert(String source) {

		DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
		try {
			LocalDateTime ldt = LocalDateTime.parse(source, df);
			return ldt;
		} catch (DateTimeParseException e) {
			e.printStackTrace();
			return null;
		}

	}
}
